﻿Imports Mystery

Public Class BooleanFilter
    Implements IPropertyFilterControl

    Private _content_property As ContentProperty

    Public Property content_property As System.Reflection.PropertyInfo Implements IPropertyFilterControl.content_property
        Get
            Return _content_property.used_in
        End Get
        Set(value As System.Reflection.PropertyInfo)
            _content_property = value.getMysteryAttribute(Of ContentProperty)()
        End Set
    End Property

    Public Property label As String Implements IPropertyFilterControl.label

    Public Event haveChanged() Implements IPropertyFilterControl.haveChanged

    Private Sub cbValue_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles cbValue.SelectionChanged
        RaiseEvent haveChanged()
    End Sub

    Public Function Match(content As Mystery.IContent) As Boolean Implements IPropertyFilterControl.Match
        If cbiAll.IsSelected Then Return True
        Dim value As Boolean = cbiYes.IsSelected 'otherwise is no automatically
        Dim content_value As Object = _content_property.retrive(content)
        If TypeOf (content_value) Is ContentPropertyValue Then content_value = DirectCast(content_value, ContentPropertyValue).getValue
        Return content_value = value
    End Function
End Class
